/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package kimo.persistence.entities;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author a381u296
 */
@Entity
@Table(name = "prefecture")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Prefecture.findAll", query = "SELECT p FROM Prefecture p"),
    @NamedQuery(name = "Prefecture.findByPrefectureId", query = "SELECT p FROM Prefecture p WHERE p.prefectureId = :prefectureId"),
    @NamedQuery(name = "Prefecture.findByPrefectureName", query = "SELECT p FROM Prefecture p WHERE p.prefectureName = :prefectureName")})
public class Prefecture implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "prefecture_id")
    private String prefectureId;
    @Basic(optional = false)
    @Column(name = "prefecture_name")
    private String prefectureName;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "municipalityPrefectureId")
    private List<Municipality> municipalityList;
    @JoinColumn(name = "prefecture_region_id", referencedColumnName = "region_id")
    @ManyToOne(optional = false)
    private Region prefectureRegionId;

    public Prefecture() {
    }

    public Prefecture(String prefectureId) {
        this.prefectureId = prefectureId;
    }

    public Prefecture(String prefectureId, String prefectureName) {
        this.prefectureId = prefectureId;
        this.prefectureName = prefectureName;
    }

    public String getPrefectureId() {
        return prefectureId;
    }

    public void setPrefectureId(String prefectureId) {
        this.prefectureId = prefectureId;
    }

    public String getPrefectureName() {
        return prefectureName;
    }

    public void setPrefectureName(String prefectureName) {
        this.prefectureName = prefectureName;
    }

    @XmlTransient
    public List<Municipality> getMunicipalityList() {
        return municipalityList;
    }

    public void setMunicipalityList(List<Municipality> municipalityList) {
        this.municipalityList = municipalityList;
    }

    public Region getPrefectureRegionId() {
        return prefectureRegionId;
    }

    public void setPrefectureRegionId(Region prefectureRegionId) {
        this.prefectureRegionId = prefectureRegionId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (prefectureId != null ? prefectureId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Prefecture)) {
            return false;
        }
        Prefecture other = (Prefecture) object;
        if ((this.prefectureId == null && other.prefectureId != null) || (this.prefectureId != null && !this.prefectureId.equals(other.prefectureId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return prefectureName;
    }
    
}
